#include <stdio.h>
#include <string.h>

/**
 * 声明、初始化和输出字符串及理解内存布局
 */
int main() {
	char aa, bb[4], cc[100], dd[100];
	// 文件输出
	FILE *output_stream = fopen("C7_1.OUT", "w");
	aa = 'g';
	bb[0] = 'C';
	bb[1] = 'a';
	bb[2] = 't';
	bb[3] = '\0'; // 字符串终止符
	// 将字符串copy到字符数组
	strcpy(cc, "This is a string constant, also called a string literal.");
	strcpy(dd, cc);

	// 单独字符
	putchar(aa);
	putc(aa, output_stream);
	fputc('\n', output_stream);
	fputc(aa, output_stream);
	fputc('\n', output_stream);

	puts(bb);
	fputs(bb, output_stream);
	fputc('\n', output_stream);
	printf("%s", bb);
	fprintf(output_stream, "%s", bb);
	fputc('\n', output_stream);

	fputs(cc, output_stream);
	fputc('\n', output_stream);
	puts(dd);
	fputs(dd, output_stream);

	// 关闭文件
	fclose(output_stream);

}